var names = [
	"彭俊哲",
	"黎欣媛",
	"朱小楠",
	"温悦幸",
	"罗紫宜",
	"彭康丽",
	"姚安琪",
	"叶宏坤",
	"高雨扬",
	"钟睿立",
	"施嵛曦",
	"魏文佳",
	"张锦轩",
	"陈思羽",
	"黄梓娇",
	"黄思愉",
	"王炜珊",
	"张金霞",
	"邹雨萱",
	"张诗雅",
	"巫芷晴",
	"邓嘉和",
	"廖政凯",
	"杨云峻",
	"黄宥淳",
	"张煜山",
	"黄烨帆",
	"伍谷城",
	"曹晓文",
	"易彬欣",
	"杨晓妍",
	"陈睿馨",
	"温灿",
	"曾子航",
	"张文锋",
	"欧阳敏",
	"罗小米",
	"谢孟晓",
	"丁怡",
	"邱琪涵",
	"程雯钮",
	"谢璐",
	"李煜凯",
	"李清聪",
	"李米煜",
	"朱睿浩",
	"罗鑫",
	"许德淋",
	"王诺然",
	"施佳洪",
	"谢洁如",
	"胡高阳",
	"陈彦均",
	"杨润东",
	"何岸颖",
	"贺天佑"
];

var drawname;
var index = -1;
var time;
var flag = 1;

function btnOnclick() {
	if (flag % 2 == 1) {
		begin();
		document.getElementById("BTN").value = "按A暂停";
	}
	if (flag % 2 == 0) {
		end();
		document.getElementById("BTN").value = "按A开始";
	}
	flag++;
}

function begin() {
	document.getElementById("BTN").disabled = false;
	draw();
}

function draw() {
	if (names.length > 0) {
		index = Math.floor(Math.random() * 1000 % names.length);
		drawname = names[index];
		document.getElementById("result").innerHTML = drawname;

		time = window.setTimeout(draw, 2);
	} else {
		document.getElementById("result").innerHTML = "~请刷新网页~";
	}
}

function speech() {
	var url = "https://fanyi.sogou.com/reventondc/synthesis?text=" + drawname +
		"&speed=0.7&lang=zh-CHS&from=translateweb&speaker=2";
	new Audio(url).play();
}

function end() {
	speech();
	window.clearTimeout(time);
	document.getElementById("BTN").disabled = false;
	names.splice(index, 1);
}
